<template>
	<view class="pl-30 pr-30">
		<view class="bg-white mt-10">
			<view class="padding-30 border-b">{{cardData.cardItemName}}</view>
			<view class="flex padding-30" @click="showDate = true">
				<text class="mr-30">到期时间</text>
				<u-input :value="cardData.validityDate" disabled disabledColor="#fff" placeholder="请选择到期时间" border="none">
					<template slot="suffix">
						<u-icon size="16" name="arrow-right" color="#aaa"/>
					</template>
				</u-input>
			</view>
		</view>
		<view class="padding-60">
			<u-button text="确定" color="#e54d42" @click="onSubmit"></u-button>
		</view>
		<u-datetime-picker
			:show="showDate"
			v-model="date"
			:closeOnClickOverlay="true"
			mode="date"
			@confirm="onConfirmDate"
		/>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data(){
			return {
				showDate: false,
				date:Number(new Date()),
				cardData:{}
			}
		},
		onLoad(opt) {
			this.cardData = opt
		},
		methods: {
			onConfirmDate(e){
				this.showDate = false
				this.cardData.validityDate = uni.$u.date(e.value, 'yyyy-mm-dd')
			},
			onSubmit(){
				let da = this.cardData.validityDate
				if(uni.$u.test.isEmpty(da)){
					this.$refs.uToast.show({message: "请选择到期时间"})
				}else {
					this.$reqJsonPost('CardOrderDoEdit', this.cardData).then(res=>{
						this.$refs.uToast.show({
							message: res.msg,
							complete(){
								uni.$emit('uplist', 0)
								uni.navigateBack()
							}
						})
					})
				}
			}
		}
	}
</script>

<style>
</style>